# $Id$
# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Roman Kyrylych <roman@archlinux.org>
# Contributor: Damir Perisa <damir@archlinux.org>

pkgname=hddtemp
_origver=0.3-beta15
_patchver=${_origver}-52
pkgver=${_patchver//-/.}
pkgrel=2
pkgdesc="Gives you the temperature of your hard drive by reading S.M.A.R.T. information"
url='https://savannah.nongnu.org/projects/hddtemp/'
license=('GPL')
arch=('i686' 'x86_64')
validpgpkeys=('758514A863A879595EB4FDA824011CEE33F10AF1')
source=("http://download.savannah.gnu.org/releases/${pkgname}/${pkgname}-${_origver}.tar.bz2"{,.sig}
        "http://ftp.debian.org/debian/pool/main/h/${pkgname}/${pkgname}_${_patchver}.diff.gz"
        'service')
sha256sums=('618541584054093d53be8a2d9e81c97174f30f00af91cb8700a97e442d79ef5b'
            'SKIP'
            '2466eabe4011042d4011831d40e4e207c810454a0320d77ba99e0b87cdfd8bb6'
            '7f6fda4379630a21a8014d8f471eef6451fa15d73df32ec90a85d6a3f9d0c7d4')

prepare() {
	cd "${srcdir}/${pkgname}-${_origver}"

	patch -p1 -i "../${pkgname}_${_patchver}.diff"
}

build() {
	cd "${srcdir}/${pkgname}-${_origver}"

	./configure \
		--prefix=/usr \
		--sbindir=/usr/bin \
		--mandir=/usr/share/man \
		--with-db-path="/usr/share/${pkgname}/hddtemp.db"

	make
}

package() {
	cd "${srcdir}/${pkgname}-${_origver}"

	make DESTDIR="${pkgdir}" install

	install -Dm644 "../${pkgname}-${_origver}/debian/hddtemp.db" "${pkgdir}/usr/share/${pkgname}/hddtemp.db"
	install -Dm644 '../service' "${pkgdir}/usr/lib/systemd/system/hddtemp.service"
}
